﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

namespace NCRGEA.Reports
{
    public partial class frmMemInfoReport : Form
    {
        int _MemberID;

        public frmMemInfoReport()
        {
            InitializeComponent();
        }

        public frmMemInfoReport(int MemberID) : this()
        {
            _MemberID = MemberID;
        }

        private void frmMemInfoReport_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'nCRGEADataSet.memInfo' table. You can move, or remove it, as needed.
            this.memInfoTableAdapter.Fill(this.nCRGEADataSet.memInfo, _MemberID);
            this.paymentsTableAdapter.Fill(this.nCRGEADataSet.payments, _MemberID);
            this.plansTableAdapter.Fill(this.nCRGEADataSet.plans, _MemberID);
            this.reportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
            this.reportViewer1.RefreshReport();
        }

        void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
        {
            switch (e.ReportPath)
            {
                case "Last3Payments":
                    Microsoft.Reporting.WinForms.ReportDataSource rptDSPayments = new Microsoft.Reporting.WinForms.ReportDataSource();
                    rptDSPayments.Name = "dsPayments";
                    rptDSPayments.Value = this.paymentsBindingSource;
                    e.DataSources.Add(rptDSPayments);
                    break;
                case "PlansReport":
                    Microsoft.Reporting.WinForms.ReportDataSource rptDSPlans = new Microsoft.Reporting.WinForms.ReportDataSource();
                    rptDSPlans.Name = "dsPlans";
                    rptDSPlans.Value = this.plansBindingSource;
                    e.DataSources.Clear();
                    e.DataSources.Add(rptDSPlans);
                    break;
            }

        }


    }
}
